package com.eqdd.yiqidian.ui.mine.renwu;

import android.databinding.DataBindingUtil;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;

import com.eqdd.yiqidian.R;
import com.eqdd.yiqidian.RenwuStaffListActivityCustom;
import com.eqdd.yiqidian.adapter.slimadapter.SlimAdapterEx;
import com.eqdd.yiqidian.adapter.slimadapter.SlimInjector;
import com.eqdd.yiqidian.adapter.slimadapter.viewinjector.IViewInjector;
import com.eqdd.yiqidian.base.BaseActivity;
import com.eqdd.yiqidian.bean.rebuild.RenwuInfoResultBean;
import com.eqdd.yiqidian.utils.IMUtil;
import com.eqdd.yiqidian.utils.ImageUtil;

import java.util.List;

import io.rong.imkit.RongIM;

public class RenwuStaffListActivity extends BaseActivity {
    private RenwuStaffListActivityCustom dataBinding;
    private SlimAdapterEx slimAdapterEx;
    private List<RenwuInfoResultBean.RenwuStaffBean> datas;

    @Override
    public void initBinding() {
        dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_renwu_staff_list);
        initTopTitleBar(View.VISIBLE, "人员");
    }

    @Override
    public void initData() {
        dataBinding.recyclerView.setLayoutManager(new LinearLayoutManager(this));
        slimAdapterEx = SlimAdapterEx.create().register(R.layout.list_item_34, new SlimInjector<RenwuInfoResultBean.RenwuStaffBean>() {
            @Override
            public void onInject(RenwuInfoResultBean.RenwuStaffBean data, IViewInjector injector) {

                injector.text(R.id.tv_left_center_content, data.getName())
                        .text(R.id.tv_upper_content, data.getDepartment())
                        .text(R.id.tv_down_content, data.getPost())
                        .with(R.id.iv_head, v -> ImageUtil.setCircleImage(data.getHeadImage(), (ImageView) v))
                        .clicked(R.id.bt_right, v ->
                                        IMUtil.startPrivate(RenwuStaffListActivity.this, data.getGuid(), data.getName(),data.getHeadImage()));
            }
        }).attachTo(dataBinding.recyclerView);
    }

    @Override
    public void setView() {

        datas = getIntent().getParcelableArrayListExtra("list");
        slimAdapterEx.updateData(datas);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {

        }
    }
}
